home *** CD-ROM | disk | FTP | other *** search
/ Freelog 121 / FreelogMagazineJuilletAout2014-No121.iso / Outils / Adobe-Air / adobe-air_13.exe / [0] / setup.swf / scripts / mx / containers / FormHeading.as < prev    next >
Text File  |  2014-03-27  |  4KB  |  134 lines

  1. package mx.containers
  2. {
  3.    import flash.events.Event;
  4.    import mx.controls.Label;
  5.    import mx.core.EdgeMetrics;
  6.    import mx.core.UIComponent;
  7.    import mx.core.mx_internal;
  8.    
  9.    use namespace mx_internal;
  10.    
  11.    public class FormHeading extends UIComponent
  12.    {
  13.       
  14.       mx_internal static const VERSION:String = "3.0.0.0";
  15.        
  16.       
  17.       private var labelObj:Label;
  18.       
  19.       private var _label:String = "";
  20.       
  21.       public function FormHeading()
  22.       {
  23.          super();
  24.       }
  25.       
  26.       private function getLabelWidth() : Number
  27.       {
  28.          var _loc1_:Number = getStyle("labelWidth");
  29.          if(_loc1_ == 0)
  30.          {
  31.             _loc1_ = NaN;
  32.          }
  33.          if(isNaN(_loc1_) && parent is Form)
  34.          {
  35.             _loc1_ = Form(parent).calculateLabelWidth();
  36.          }
  37.          if(isNaN(_loc1_))
  38.          {
  39.             _loc1_ = 0;
  40.          }
  41.          return _loc1_;
  42.       }
  43.       
  44.       override protected function commitProperties() : void
  45.       {
  46.          super.commitProperties();
  47.          createLabel();
  48.       }
  49.       
  50.       [Bindable("labelChanged")]
  51.       public function get label() : String
  52.       {
  53.          return _label;
  54.       }
  55.       
  56.       override protected function updateDisplayList(param1:Number, param2:Number) : void
  57.       {
  58.          var _loc3_:Number = NaN;
  59.          var _loc4_:Number = NaN;
  60.          var _loc5_:Number = NaN;
  61.          var _loc6_:EdgeMetrics = null;
  62.          super.updateDisplayList(param1,param2);
  63.          if(labelObj)
  64.          {
  65.             _loc3_ = getStyle("indicatorGap");
  66.             _loc4_ = getStyle("paddingTop");
  67.             _loc5_ = width;
  68.             labelObj.move(getLabelWidth() + _loc3_,_loc4_);
  69.             if(parent && parent is Form)
  70.             {
  71.                _loc6_ = Form(parent).viewMetricsAndPadding;
  72.                _loc5_ = parent.width - (getLabelWidth() + _loc3_ + _loc6_.left + _loc6_.right);
  73.             }
  74.             labelObj.setActualSize(_loc5_,height);
  75.          }
  76.       }
  77.       
  78.       public function set label(param1:String) : void
  79.       {
  80.          _label = param1;
  81.          invalidateProperties();
  82.          dispatchEvent(new Event("labelChanged"));
  83.       }
  84.       
  85.       override protected function measure() : void
  86.       {
  87.          super.measure();
  88.          var _loc1_:Number = 0;
  89.          var _loc2_:Number = getStyle("paddingTop");
  90.          if(labelObj)
  91.          {
  92.             if(isNaN(labelObj.measuredWidth))
  93.             {
  94.                labelObj.validateSize();
  95.             }
  96.             _loc1_ = labelObj.measuredWidth;
  97.             _loc2_ += labelObj.measuredHeight;
  98.          }
  99.          _loc1_ += getLabelWidth() + getStyle("indicatorGap");
  100.          measuredMinWidth = _loc1_;
  101.          measuredMinHeight = _loc2_;
  102.          measuredWidth = _loc1_;
  103.          measuredHeight = _loc2_;
  104.       }
  105.       
  106.       private function createLabel() : void
  107.       {
  108.          if(_label.length > 0)
  109.          {
  110.             if(!labelObj)
  111.             {
  112.                labelObj = new Label();
  113.                labelObj.styleName = this;
  114.                addChild(labelObj);
  115.             }
  116.             if(labelObj.text != _label)
  117.             {
  118.                labelObj.text = _label;
  119.                labelObj.validateSize();
  120.                invalidateSize();
  121.                invalidateDisplayList();
  122.             }
  123.          }
  124.          if(_label.length == 0 && labelObj)
  125.          {
  126.             removeChild(labelObj);
  127.             labelObj = null;
  128.             invalidateSize();
  129.             invalidateDisplayList();
  130.          }
  131.       }
  132.    }
  133. }
  134.